home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / stringnode_examples / stringnode_example4.e < prev    next >
Text File  |  1995-11-07  |  1KB  |  48 lines

  1. /*
  2. ** StringNode Example-4
  3. **
  4. ** add(), search() AND insert() methods.
  5. **
  6. ** (C)Copyright 1995 Fabio Rotondo
  7. **
  8. ** e-mail: fosft@intercom.it
  9. */
  10.  
  11. MODULE 'fabio/StringNode_oo'   -> Our MAGIC MODULE
  12.  
  13. PROC main()
  14.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  15.  
  16.   NEW n.stringnode()           -> OBJECT initialization
  17.  
  18.   n.add('Zorro')              -> Here we add some items...
  19.   n.add('Batman')
  20.   n.add('Superman')
  21.   n.add('Gold Drake')
  22.   n.add('Mandrake')
  23.   n.add('MOMMY')
  24.  
  25.   shwall(n)                   -> Here we see them
  26.  
  27.   n.search('bat')             -> The search is CASE insensitive AND match the first one ;)
  28.   WriteF('Current:\s\n', n.name()) -> Here we are!
  29.  
  30.   n.insert('Spiderman')       -> Wow! Another super-hero after Batman!
  31.   shwall(n)
  32.  
  33.   END n                       -> Remember ALWAYS TO end an OBJECT
  34. ENDPROC
  35.  
  36. PROC shwall(n:PTR TO stringnode)
  37.   WriteF('------- \d ----------\n', n.numitems())
  38.  
  39.   IF n.first()                      -> Here we go TO the first node item
  40.     REPEAT
  41.       WriteF('Node:\s\n', n.name()) -> Node STRING...
  42.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  43.   ELSE
  44.     WriteF('No Nodes in LIST...\n')
  45.   ENDIF
  46. ENDPROC
  47.  
  48.